From 42deed4d166571d5fcc8ce015281ceec1edf6047 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Wed, 2 May 2012 23:00:46 +0200 Subject: [PATCH] tests: split utility function out into common.inc --- tests/common.inc | 24 ++++++++++++++++++++++++ tests/extract.c | 28 +--------------------------- tests/floatclamp.c | 26 +------------------------- tests/palette.c | 28 +--------------------------- 4 files changed, 27 insertions(+), 79 deletions(-) create mode 100644 tests/common.inc diff --git a/tests/common.inc b/tests/common.inc new file mode 100644 index 0000000..8d573fd --- /dev/null +++ b/tests/common.inc @@ -0,0 +1,24 @@ + +#define CHECK_CONV(test_name, componenttype, src_fmt, dst_fmt, src_pix, expected_pix) \ + { \ + const Babl *fish; \ + int i; \ + fish = babl_fish (src_fmt, dst_fmt); \ + if (!fish) \ + { \ + printf (" %s failed to make fish\n", test_name); \ + OK = 0; \ + } \ + for (i = 0; i < sizeof(src_pix)/sizeof(src_pix[0]); i ++) \ + { \ + int c;\ + componenttype result[10]; \ + babl_process (fish, src_pix[i], result, 1); \ + for (c = 0; c < sizeof(expected_pix[i])/sizeof(expected_pix[i][0]); c++) \ + if (result[c] != expected_pix[i][c]) \ + { \ + printf (" %s failed #%i[%i] got %i expected %i\n", test_name, i, c, result[c], expected_pix[i][c]); \ + OK = 0; \ + } \ + } \ + } diff --git a/tests/extract.c b/tests/extract.c index 038c667..f27662b 100644 --- a/tests/extract.c +++ b/tests/extract.c @@ -21,33 +21,7 @@ #include #include #include "babl.h" - - -#define CHECK_CONV(test_name, componenttype, src_fmt, dst_fmt, src_pix, expected_pix) \ - { \ - const Babl *fish; \ - int i; \ - fish = babl_fish (src_fmt, dst_fmt); \ - if (!fish) \ - { \ - printf (" %s failed to make fish\n", test_name); \ - OK = 0; \ - } \ - for (i = 0; i < sizeof(src_pix)/sizeof(src_pix[0]); i ++) \ - { \ - int c;\ - componenttype result[10]; \ - babl_process (fish, src_pix[i], result, 1); \ - for (c = 0; c < sizeof(expected_pix[i])/sizeof(expected_pix[i][0]); c++) \ - if (result[c] != expected_pix[i][c]) \ - { \ - printf (" %s failed #%i[%i] got %i expected %i\n", test_name, i, c, result[c], expected_pix[i][c]); \ - OK = 0; \ - } \ - } \ - } - -#include +#include "common.inc" int main (int argc, diff --git a/tests/floatclamp.c b/tests/floatclamp.c index 617b440..4ba7992 100644 --- a/tests/floatclamp.c +++ b/tests/floatclamp.c @@ -22,32 +22,8 @@ #include #include "babl.h" +#include "common.inc" -#define CHECK_CONV(test_name, componenttype, src_fmt, dst_fmt, src_pix, expected_pix) \ - { \ - const Babl *fish; \ - int i; \ - fish = babl_fish (src_fmt, dst_fmt); \ - if (!fish) \ - { \ - printf (" %s failed to make fish\n", test_name); \ - OK = 0; \ - } \ - for (i = 0; i < sizeof(src_pix)/sizeof(src_pix[0]); i ++) \ - { \ - int c;\ - componenttype result[10]; \ - babl_process (fish, src_pix[i], result, 1); \ - for (c = 0; c < sizeof(expected_pix[i])/sizeof(expected_pix[i][0]); c++) \ - if (result[c] != expected_pix[i][c]) \ - { \ - printf (" %s failed #%i[%i] got %i expected %i\n", test_name, i, c, result[c], expected_pix[i][c]); \ - OK = 0; \ - } \ - } \ - } - -#include int main (int argc, diff --git a/tests/palette.c b/tests/palette.c index 6ad517f..aaf98c8 100644 --- a/tests/palette.c +++ b/tests/palette.c @@ -21,33 +21,7 @@ #include #include #include "babl.h" - - -#define CHECK_CONV(test_name, componenttype, src_fmt, dst_fmt, src_pix, expected_pix) \ - { \ - const Babl *fish; \ - int i; \ - fish = babl_fish (src_fmt, dst_fmt); \ - if (!fish) \ - { \ - printf (" %s failed to make fish\n", test_name); \ - OK = 0; \ - } \ - for (i = 0; i < sizeof(src_pix)/sizeof(src_pix[0]); i ++) \ - { \ - int c;\ - componenttype result[10]; \ - babl_process (fish, src_pix[i], result, 1); \ - for (c = 0; c < sizeof(expected_pix[i])/sizeof(expected_pix[i][0]); c++) \ - if (result[c] != expected_pix[i][c]) \ - { \ - printf (" %s failed #%i[%i] got %i expected %i\n", test_name, i, c, result[c], expected_pix[i][c]); \ - OK = 0; \ - } \ - } \ - } - -#include +#include "common.inc" int main (int argc, -- 2.30.2